<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/jstl.jspf"%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>重置密码</title>
		<link rel="stylesheet" href="${url}/css/common.css" />
		<link rel="stylesheet" href="${url}/css/register.css" />
		<link rel="stylesheet" href="${url}/css/password-reminder.css" />
		<link rel="Shortcut Icon" href="${url}/img/favicon.ico">
	</head>
<script src="${url }/js/jquery-3.1.1.min.js"></script>
	<body>
		<div class="login-top">
			<a href="index.html"><div class="logo"></div></a>
		</div>
		<div class="register-bottom">
			<div class="login-bottom-text">
				-专注互联网职业机会-
			</div>
		</div>
		<div class="register-main">
			<div class="retrieve-title">
				重置登录密码
			</div>
			<form action="${url}/user/user_updatePass.action" method="post">
			<input type="text" value="${user.username }">
			<input type="text" id="auserid" name="user.id" value="${user.id }">
			<div class="new-password">
				<input type="text"  onblur="ajaxcheckpass(this);" id="oldPass" placeholder="请输入原始密码" /><span></span>
			</div>
			<div class="new-password">
				<input type="password" id="userpassword" name="user.password" placeholder="请输入新的登录密码" autofocus/>
			</div>
			<div class="again-password">
				<input type="password" id="cpassword" onkeyup="retypepassword(this)" placeholder="请再次输入新的登录密码"/><span></span>
			</div>
			<div class="verify-again">
				<input type="text" id="codenumber" onblur="checkcode(this)" name="codenum" placeholder="请输入验证码"/><span></span>
				<img  id="codeimg" src="<%=request.getContextPath() %>/kaptcha.jpg" title="看不清楚？点击更换图片" style="cursor: pointer;" onclick="changeValidateCode(this)">
			</div>
			<div class="reset-button">
				
				<input type="submit" id="respsd" disabled value="重置密码"/>
			</div>
			</form>
		</div>

	</body>
<script type="text/javascript">

function changeValidateCode(obj){
	 obj.src='<%=request.getContextPath() %>/kaptcha.jpg?time='+new Date().getTime();
	 
}
function ajaxcheckpass(obj){
	 var pass=obj.value;
	 var userid=document.getElementById("auserid").value;
	 var id = obj.id;
	 var urlhttp="<%=request.getContextPath() %>/user/user_checkpass.action" ;
	 $.ajax({
		 type:'post',
	     data:{'user.id':userid,
	           'user.password':pass	 
	            },
	     url:urlhttp,
	     dataType:'text',
	     success:function(data){
	    		if(data=="ok"){
	    			$("#" + id ).next().html("正确");
	    			$("#" + id ).next().css("color","green");
	    			document.getElementById("respsd").disabled=false;
	    		}else{
	    			$("#" + id ).next().html(data);
	    			$("#" + id ).next().css("color","red");
	    			$("#" + id ).focus();
	    			document.getElementById("respsd").disabled=true;
	    		}
	    	},    	
	 })	
}
function checkcode(obj){
	var code=obj.value;
	 var id = obj.id;
	 var urlhttp="<%=request.getContextPath() %>/user/user_checkCode.action" ;
	 $.ajax({
		 type:'post',
	     data:{'checkCode':code,
	           	 },
	     url:urlhttp,
	     dataType:'text',
	     success:function(data){
	    		if(data=="ok"){
	    			$("#" + id ).next().html("正确");
	    			$("#" + id ).next().css("color","green");	
	    			document.getElementById("respsd").disabled=false;
	    		}else{
	    			$("#" + id ).next().html(data);
	    			$("#" + id ).next().css("color","red");
	    			$("#" + id ).focus();
	    			document.getElementById("respsd").disabled=true;
	    		}
	    	},    	
	 })	
}
function retypepassword(obj){
	var checkPass=obj.value;
	var id=obj.id;
	var firstPass=$("#userpassword").val();
	
	if(checkPass==firstPass){
		$("#" + id ).next().html("正确");
		$("#" + id ).next().css("color","green");
		
	}else{
		$("#" + id ).next().html("两次输入密码不一致！请重新输入！");
		$("#" + id ).next().css("color","red");
		$("#" + id ).focus();
		document.getElementById("respsd").disabled=true;
	}
}



</script>
</html>